<?php /*a:2:{s:70:"/www/wwwroot/pay.rym.best/application/admin/view/order/settlement.html";i:1563242528;s:65:"/www/wwwroot/pay.rym.best/application/admin/view/common/head.html";i:1563242522;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title><?php echo config('sys_name'); ?>后台管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="shortcut icon" href="/favicon.ico"/>  
    <link rel="stylesheet" href="/static/plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/static/admin/css/global.css" media="all">
    <link rel="stylesheet" href="/static/common/css/font.css" media="all">
</head>
<body class="skin-<?php if(!empty($_COOKIE['skin'])){echo $_COOKIE['skin'];}else{echo '0';setcookie('skin','0');}?>"> 
<div class="admin-main">
    <fieldset class="layui-elem-field layui-field-title"><legend>订单结算单</legend></fieldset>
    <a href="<?php echo url('settlement'); ?>" class="layui-btn layui-btn-sm"><i class="layui-icon">&#xe857;</i>所有结算单明细</a>  
    <div class="layui-btn layui-btn-sm layui-btn-danger"><i class="layui-icon"></i>以下统计订单为 “已确认” 并且 “未结算” 状态的订单金额及订单数！</div>
	<div class="layui-form layui-row" style="overflow: hidden;">  
		<table class="layui-table"> 
		<tbody>
			<tr>
				<td>今日未结算订单</td><td><?php echo htmlentities($money_today); ?>/元</td><td><?php echo htmlentities($order_today); ?>/个订单</td>
				<td><?php if($money_today): ?><div class="layui-btn layui-btn-xs" onclick="tojiesuan('today')">结算今日所有订单</div><?php else: ?><div class="layui-btn layui-btn-disabled layui-btn-xs">暂无订单</div><?php endif; ?></td>
				<td>本周未结算订单</td><td><?php echo htmlentities($money_week); ?>/元</td><td><?php echo htmlentities($order_week); ?>/个订单</td> 
				<td><?php if($money_week): ?><div class="layui-btn layui-btn-xs" onclick="tojiesuan('week')">结算本周所有订单</div><?php else: ?><div class="layui-btn layui-btn-disabled layui-btn-xs">暂无订单</div><?php endif; ?></td>
			</tr> 
			<tr>
				<td>昨日未结算订单</td><td><?php echo htmlentities($money_yesterday); ?>/元</td><td><?php echo htmlentities($order_yesterday); ?>/个订单</td> 
				<td><?php if($money_yesterday): ?><div class="layui-btn layui-btn-xs" onclick="tojiesuan('yesterday')">结算昨日所有订单</div><?php else: ?><div class="layui-btn layui-btn-disabled layui-btn-xs">暂无订单</div><?php endif; ?></td>
				<td>上周未结算订单</td><td><?php echo htmlentities($money_lastweek); ?>/元</td><td><?php echo htmlentities($order_lastweek); ?>/个订单</td> 
				<td><?php if($money_lastweek): ?><div class="layui-btn layui-btn-xs" onclick="tojiesuan('last week')">结算上周所有订单</div><?php else: ?><div class="layui-btn layui-btn-disabled layui-btn-xs">暂无订单</div><?php endif; ?></td>
			</tr>  
            <tr>
                <td>所有未结算订单</td><td><?php echo htmlentities($money_all_no); ?>/元</td><td><?php echo htmlentities($order_all_no); ?>/个订单</td> 
                <td><?php if($money_all_no): ?><div class="layui-btn layui-btn-xs" onclick="tojiesuan(0)">结算所有订单</div><?php else: ?><div class="layui-btn layui-btn-disabled layui-btn-xs">暂无订单</div><?php endif; ?></td>
                <td>所有已结算订单</td><td><?php echo htmlentities($money_all_yes); ?>/元</td><td><?php echo htmlentities($order_all_yes); ?>/个订单</td><td></td>
            </tr>  
            <tr>
                <td class="red">待收金额</td><td>+ <span style="font-size:22px"><?php echo htmlentities($money_get_no); ?></span>/元</td>
                <td class="red">待付金额</td><td>- <span style="font-size:22px"><?php echo htmlentities($money_pay_no); ?></span>/元</td>
                <td class="green">累计已收金额</td><td>+ <span style="font-size:22px"><?php echo htmlentities($money_get_yes); ?></span>/元</td>
                <td class="green">累计已付金额</td><td>- <span style="font-size:22px"><?php echo htmlentities($money_pay_yes); ?></span>/元</td>
            </tr>  

		</tbody> 
		</table> 
	</div>
	<div class="layui-clear"></div> 
    <table class="layui-table layui-hide" id="orderlist" lay-filter="listss"></table>
</div>    
<script src="/static/plugins/layui/layui.js"></script> 
<script type="text/html" id="action">
    {{# if(d.state==0){ }}
        <div class="layui-btn layui-btn-normal layui-btn-xs" lay-event="passit">处理</div>
    {{# }else{ }}
        <div class="layui-btn layui-btn-disabled layui-btn-xs">已处理</div>
    {{# } }} 
</script>
<script>
    layui.use(['layer','table','form','laydate'], function() {
        var table = layui.table,form = layui.form, layer = layui.layer;
        $ = layui.jquery;
        tableIn = table.render({
            id: 'listss',
            elem: '#orderlist', 
            url: '<?php echo url("settlement"); ?>',
            method: 'post', 
            page: true,
            cols: [[ 
                {field: 'orderid', title: '结算单号',align: 'center', width:138, fixed: true},
                {field: 'typename', title: '结算类型',align: 'center', width: 100, fixed: true},
                {field: 'money_a', title: '订单金额',align: 'center', width: 120, fixed: true}, 
                {field: 'money_s', title: '手续费',align: 'center', width: 120, fixed: true},
                {field: 'money_sf', title: '结算金额',align: 'center', width: 120, fixed: true}, 
                {field: 'state_name', title: '收付状态',align: 'center', width: 90},  
                {field: 'number', title: '订单数量',align: 'center', width: 100},
                {field: 'shopname', title: '码商/商户',align: 'center', width: 138},
                {field: 'username', title: '结算对象',align: 'center', width: 138},
                {field: 'mobile', title: '联系方式',align: 'center', width: 168},
                {field: 'addtime', title: '结算时间',align: 'center', width: 142},  
                {title: '操作', width: 80,align: 'center', fixed:'right',toolbar: '#action'},
            ]],
            limit: 60 //每页默认显示的数量
        }); 
        table.on('tool(listss)', function(obj) {
            var data = obj.data;
            if(obj.event === 'passit') {
            	var type=data.type; 
            	tipss='您将进行款项操作，请慎重？';
                layer.confirm(tipss, function(index){ 
                    $.post("<?php echo url('pass_jiesuan'); ?>",{id:data.id},function(res){
                        if(res.code===1){
                            layer.msg(res.msg,{time:1000,icon:1},function(){ 
                            	tableIn.reload();
                            });
                        }else{
                            layer.msg(res.msg,{time:1000,icon:2});
                        }
                    });
                    layer.close(index);
                });
            }
        });  
    });
    function tojiesuan(timequ){
        $.post("jieshu",{timequ:timequ}, function (res) { 
            if (res.code === 1) {
                layer.msg(res.msg, {time: 1500, icon: 1}, function () {
                    $.post("jieshu_shop",{timequ:timequ}, function (res) { 
			            if (res.code === 1) {
			                layer.msg(res.msg, {time: 1000, icon: 1}, function () {
			                	$.post("jieshu_agent",{timequ:timequ}, function (res) { 
                                    if (res.code === 1) {
                                        layer.msg(res.msg, {time: 1000, icon: 1}, function () {
                                            tableIn.reload();     
                                        });
                                    } else {
                                        layer.msg(res.msg, {time: 1000, icon: 2});
                                    }
                                });
			                });
			            } else {
			                layer.msg(res.msg, {time: 1000, icon: 2});
			            }
			        });
                });
            } else {
                layer.msg(res.msg, {time: 1000, icon: 2});
            }
        });
    }
</script>
</body>
</html>